//声明函数，用来获取必抢的数据
function getQiangList() {
    axios.get('http://81.71.65.4:3008/show/qiang').then(function (result) {
        console.log(result.data.data)
        var list=result.data.data
        var qiangHtml=''
        for(var item in list){
            qiangHtml+=
            `<div>
            <img src="${list[item].posterUrl}" alt="">
            <p>即将开抢${list[item].showTime}</p>
            <p>${list[item].name}</p>
          </div>`
        }
        document.querySelector('.main').innerHTML=qiangHtml
    });
};
getQiangList();


//声明函数，用来获取必抢的数据
function getrecommended(){
    //获取数据
    axios.get('http://81.71.65.4:3008/show/list').then(function (result) {
        console.log(result.data.data)
        var list=result.data.data
        var listLeft=''
        var listRight=''
        for(var i=0;i<list.length;i++){
            if(i%2==0){
                var name;
                var showTimeRange;
                var lowestPrice;
                if(list[i].name){
                    name=list[i].name
                }else{
                    name=''
                }
                if(list[i].showTimeRange){
                    showTimeRange=list[i].showTimeRange
                }else{
                    showTimeRange=''
                }
                if(list[i].lowestPrice){
                    lowestPrice=` ￥ ${list[i].lowestPrice} 起`
                }else{
                    lowestPrice=''
                }
                listLeft+=
                `<div>
                    <img src="${list[i].posterUrl}" alt="">
                    <p>${name}</p>
                    <p>${showTimeRange}</p>
                    <p>${lowestPrice} </p>
                </div>`
            }else{
                var name;
                var showTimeRange;
                var lowestPrice;
                if(list[i].name){
                    name=list[i].name
                }else{
                    name=''
                }
                if(list[i].showTimeRange){
                    showTimeRange=list[i].showTimeRange
                }else{
                    showTimeRange=''
                }
                if(list[i].lowestPrice){
                    lowestPrice=` ￥ ${list[i].lowestPrice} 起`
                }else{
                    lowestPrice=''
                }
                listRight+=
                `<div>
                    <img src="${list[i].posterUrl}" alt="">
                    <p>选购座位</p>
                    <p>${name}</p>
                    <p>${showTimeRange}</p>
                    <p> ${lowestPrice}</p>
                </div>`
            }
        }
        document.querySelector('.recommended2 .left').innerHTML=listLeft
        document.querySelector('.recommended2 .right').innerHTML=listRight
    });
};
getrecommended();


